<?php

namespace backend\models;

use Yii;

/**
 * This is the model class for table "{{%ticket_patch}}".
 *
 * @property int $id
 * @property int $ticket_id
 * @property int $patch_id
 *
 * @property Patch $patch
 * @property Ticket $ticket
 */
class TicketPatch extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%ticket_patch}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['ticket_id', 'patch_id'], 'required'],
            [['ticket_id', 'patch_id'], 'integer'],
            [['patch_id'], 'exist', 'skipOnError' => true, 'targetClass' => Patch::class, 'targetAttribute' => ['patch_id' => 'id']],
            [['ticket_id'], 'exist', 'skipOnError' => true, 'targetClass' => Ticket::class, 'targetAttribute' => ['ticket_id' => 'id']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'ticket_id' => 'Ticket ID',
            'patch_id' => 'Patch ID',
        ];
    }

    /**
     * Gets query for [[Patch]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getPatch()
    {
        return $this->hasOne(Patch::class, ['id' => 'patch_id']);
    }

    /**
     * Gets query for [[Ticket]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getTicket()
    {
        return $this->hasOne(Ticket::class, ['id' => 'ticket_id']);
    }
}
